<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!--{include file='comm/header.tpl'}-->
    <!--{if $role_array}-->
    <title>角色修改</title>
    <!--{else}-->
    <title>角色新增</title>
    <!--{/if}-->
</head>
<body>
	<div style="width:100%">
		
		<div class="items clearfix">

			<h2 style="" class="tal">
				<!--{if $role_array}-->
                    正在操作：角色修改
			    <!--{else}-->
                    正在操作：角色新增
			    <!--{/if}-->
			</h2>
			
			<div class="items2">

				<form id="addForm" onsubmit="return false;">
					<table>
						<tr>
							<td width="150" class="tar">角色组：</td>
							<td width="*">
								<select name="roleGroupID" style="width:200px;">
									<option value="0">请选择</option>
									<!--{foreach from=$role_group_array item=role_group}-->
										<!--{if $role_group.roleGroupID == $role_array.roleGroupID}-->
											<option value="<!--{$role_group.roleGroupID}-->" selected="selected"><!--{$role_group.roleGroupName}--></option>
										<!--{else}-->
											<option value="<!--{$role_group.roleGroupID}-->"><!--{$role_group.roleGroupName}--></option>
										<!--{/if}-->
									<!--{/foreach}-->
								</select>
							</td>
						</tr>
						<tr>
							<td class="tar">角色名称：</td>
							<td>
								<input type="text" style="width:200px" id="roleName" name="roleName" value="<!--{$role_array.roleName}-->">
								<input type="hidden" id="roleID" name="roleID" value="<!--{$role_array.roleID}-->">
							</td>
						</tr>
						<tr>
							<td class="tar">备注：</td>
							<td>
								<textarea id="memo" name="memo" cols="60" rows="3"><!--{$role_array.memo}--></textarea>
							</td>
						</tr>
					</table>
				</form>
				
			</div>

		</div>
		
		<div class="bottom_fixbox">
			<div class="rectbox tac">
                <input type="button" class="btn" onclick="role.check();" value="保存">
				<input type="button" class="btn" onclick="E.closeWindows();" value="关闭">
	        </div>
		</div>

	</div>

<script type="text/javascript">

    var role = {

        id: <!--{$role_array.roleID|default:0}-->,

        dt: "",

        check: function() {

            this.dt = E.getFormValues("addForm");
            var error_msg = "";

            if (this.dt.roleGroupID == 0) {
                error_msg += "请选择角色组<br>";
            }
            if (E.isEmpty(this.dt.roleName)) {
                error_msg += "角色名称不能为空<br>";
            }

            if (error_msg != "") {
                E.alert(error_msg);
            } else {
                E.loadding.open("正在保存角色信息，请稍候...");
                E.ajax_post({
                    url: "/invokingAjax-backend/user/roleList.ajax?operFlg=2",
                    data: this.dt,
                    call: "role.result"
                });
            }

        },

        result: function( o ) {

            E.loadding.close();
            if (o.code == 200) {
                E.opener("role.load");
                if (!this.id) {
                    E.alert("角色保存成功", 2, "E.refresh");
                } else {
                    E.alert("角色保存成功", 2, "E.closeWindows");
                }
            } else {
                E.alert(o.message);
            }

        }

    };

</script>

</body>
</html>